@extends('public.father')
@section('css')
	<link href="/templates/hd/assets/AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css" />
	<link href="/templates/hd/assets/AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet" type="text/css" />
	<link href="/templates/hd/assets/basic/css/demo.css" rel="stylesheet" type="text/css" />
	<link href="/templates/hd/assets/css/seastyle.css" rel="stylesheet" type="text/css" />
	@endsection

@section('script')

	<script type="text/javascript" src="/templates/hd/assets/js/script.js"></script>

	
	@endsection


@section('content')
	<div class="clear"></div>
	<b class="line"></b>
	<div class="search">
		<div class="search-list">
			<div class="nav-table">
				<div class="long-title"><span class="all-goods"><a href="/">全部分类</a></span></div>
			</div>


			<div class="am-g am-g-fixed">
				<div class="am-u-sm-12 am-u-md-12">
					<div class="theme-popover">
						<div id="dianji" class="searchAbout">
							<span class="font-pale">当前位置:&nbsp;</span>

							<a id="flavor" title="首页" href="/">首页>&nbsp;</a>

							@foreach($fanxu as $v)

								<a  id="packing" href="{{route('list',$v['id'])}}">{{$v['name']}}&nbsp;></a>

							@endforeach

						</div>
						<ul class="select">
							<p class="title font-normal">
								<span class="fl">松子</span>
								<span class="total fl">搜索到<strong class="num">997</strong>件相关商品</span>
							</p>
							<div class="clear"></div>
							<li class="select-result">
								<dl>
									<dt>已选</dt>
									<dd class="select-no"></dd>
									<p class="eliminateCriteria">清除</p>
								</dl>
							</li>
							<div class="clear"></div>
							<li class="select-list">
								<dl id="select1">
									<dt class="am-badge am-round">品牌</dt>

									<div class="dd-conent">
										{{--<dd class="select-all selected"><a href="#">全部</a></dd>--}}
										@foreach($brand as $v)
											<dd onclick="pinpai(this)" @if(in_array($v['id'],explode(',',$brandid))) class="actives" @endif hd="{{$v['id']}}"><a href="javascript:;">{{$v['name']}}</a></dd>
										@endforeach

									</div>

								</dl>
							</li>




							@foreach($good['attr'] as $v)
								<li class="select-list">
								<dl id="select2">
									<dt class="am-badge am-round">{{$v['name']}}</dt>
									<div class="dd-conent">
										{{--<dd class="select-all selected" hd="0"><a href="#">全部</a></dd>--}}
										@foreach($v['son'] as $vv)
											<dd onclick="xuanze(this)" hd="{{$vv['id']}}" @if(in_array($vv['id'],explode(',',$attrids))) class="selected" @endif><a href="#">{{$vv['name']}}</a></dd>
										@endforeach
									</div>
								</dl>
							</li>
							@endforeach
						</ul>
						<div class="clear"></div>
					</div>



					<script>
						function xuanze(obj) {
							// var res = $(obj).html();
							// $('#flavor').html(res);
                            // alert(res);
							$(obj).addClass('selected').siblings('dd').removeClass('selected');
							var ids = '';
                            $.each($('.selected'),function (k, v) {
                                // alert(v);
                                //判断,如果获取到的自定义属性id为0,就不要连接在一起
                                if ($(this).attr('hd') != 0){
                                    ids += $(this).attr('hd') + ',';
                                }
                            });
                            //去掉最后的逗号
                            ids = ids.substr(0,ids.length - 1);
                            // alert(ids);
                            //使用js跳转去列表页面
                            location.href = '/list/' + {{$cid['id']}} + '/' + ids;
                        }
						function pinpai(obj) {
							$(obj).addClass('actives').siblings('dd').removeClass('actives');
							//获取当前点击id品牌id
							var pinpai = $(obj).attr('hd');
							var ids = '';
							if ($('.selected').length){
                                $.each($('.selected'),function (k, v) {
                                    // alert(v);
                                    //判断,如果获取到的自定义属性id为0,就不要连接在一起
                                    if ($(this).attr('hd') != 0){
                                        ids += $(this).attr('hd') + ',';
                                    }
                                });
                                //去掉最后的逗号
                                ids = ids.substr(0,ids.length - 1);
							}else{
							    ids = 0;
							}

                            // alert(ids);
                            //使用js跳转去列表页面
                            location.href = '/list/' + {{$cid['id']}} + '/' + ids + '/' + pinpai;
                        }








					</script>


					<div class="search-content">
						<div class="sort">
							<li class="first"><a title="综合">综合排序</a></li>
							<li><a title="价格">价格优先</a></li>
							<li class="big"><a title="评价" href="#">评价为主</a></li>
						</div>
						<div class="clear"></div>

						<ul class="am-avg-sm-2 am-avg-md-3 am-avg-lg-4 boxes">
							{{--循环分类商品数据--}}
							@foreach($good['good'] as $v)
								<li>
									<a href="{{route('detail',$v['id'])}}">

								<div class="i-pic limit">
									<img src="{{explode(',',$v['pics'])[0]}}" />


									<p class="title fl">

											【{{$v->pinpai['name']}}旗舰店】


										{{$v['title']}}


									</p>


									<p class="price fl">
										<b>¥</b>
										<strong>{{$v['mallprice']}}</strong>
									</p>
									<p class="number fl">
										销量<span>1110</span>
									</p>
								</div>
									</a>

								</li>
							@endforeach
						</ul>
					</div>
					<div class="search-side">


						<div class="side-title">
							推荐商品
						</div>
						{{--循环热门商品--}}

						@foreach($shop as $v)
						<li>
							<div class="i-pic check">
								<a href="{{route('detail',$v['id'])}}">
									<img src="{{explode(',',$v['pics'])[0]}}" />
									<p class="check-title">{{$v['title']}}</p>
									<p class="price fl">
										<b>¥</b>
										<strong>{{$v['mallprice']}}</strong>
									</p>
									<p class="number fl">
										原价<span>{{$v['goodprice']}}</span>
									</p>
								</a>

							</div>
						</li>
						@endforeach

					</div>
					<div class="clear"></div>
					{{$good['good']->links()}}

					<style>
						.pagination {
							padding-left: 0;
							margin: 1.5rem 0;
							list-style: none;
							color: #999999;
							text-align: center;
						}
						.pagination li {
							display: inline-block;
						}
						.pagination li.active span {
							display: inline-block;
							padding: 0.5em 1em;
							line-height: 1.2;
							z-index: 2;
							color: #fff;
							background-color: #0e90d2;
							border-color: #0e90d2;
							cursor: default;
						}

						.pagination li span {
							display: inline-block;
							padding: 0.5em 1em;
							line-height: 1.2;
							border: 1px solid #ddd;
							border-radius: 0;
							margin-bottom: 5px;
							margin-right: 5px;
						}

						.pagination li a {
							position: relative;
							display: block;
							padding: 0.5em 1em;
							text-decoration: none;
							line-height: 1.2;
							background-color: #fff;
							border: 1px solid #ddd;
							border-radius: 0;
							margin-bottom: 5px;
							margin-right: 5px;
						}
					</style>




				</div>
			</div>


			<hr style="margin-top: 15px">



	@endsection